﻿using System;
using System.Collections;
using System.Collections.Generic;
using Robotlegs.Bender.Extensions.EventCommand.API;
using Robotlegs.Bender.Extensions.Mediation.API;
using Robotlegs.Bender.Framework.API;
using UnityEngine;

public class MyTextConfig : IConfig
{
	[Inject]
	public IEventCommandMap eventCommandMap;
	[Inject]
	public IMediatorMap mediatorMap;
	[Inject]
	public IInjector injector;
	[Inject]
	public IContext context;


	public void Configure()
	{
		//中间介绑定
		mediatorMap.Map<MyTextView>().ToMediator<MyTextMediator>();

		//事件绑定
		eventCommandMap.Map(ViewEvent.Type.REQUEST).ToCommand<RequestCommand>();
		eventCommandMap.Map(ViewEvent.Type.ADD).ToCommand<AddCommand>();

		//注入绑定
		injector.Map<InterfaceScoreService>().ToSingleton<ScoreService>();
		injector.Map<ScoreModel>().ToSingleton<ScoreModel>();

		context.AfterInitializing(StartApplication);
	}

	private void StartApplication()
	{
		GameObject gameobj = GameObject.FindGameObjectWithTag("Text");
		gameobj.AddComponent<MyTextView>();
	}
}
